#include <STC89C5xRC.H>
#include "onewire.h"

#define ds18b20_skip_rom 0xcc
#define ds18b20_convert_T 0x44
#define ds18b20_read_scratchpad 0xBE


void ds18b20_convertT()
{
	onewire_init();
	onewire_sendbyte(ds18b20_skip_rom);
	onewire_sendbyte(ds18b20_convert_T);
}

float ds18b20_readT()
{
	unsigned char TLSB,TMSB;
	int temp;
	float T;
	onewire_init();
	onewire_sendbyte(ds18b20_skip_rom);
	onewire_sendbyte(ds18b20_read_scratchpad);
	TLSB=one_receivebyte();
	TMSB=one_receivebyte();
	temp=(TMSB<<8) | TLSB;
	T=temp/16.0;
	return T;
	
}